Attribute VB_Name = "modControls"
Option Explicit

' From X11Color.h : header file
Public Const colorAmptekBlue = &HFCCE7A
Public Const colorBlue = &HFF0000
Public Const colorGreen = &H8000&
Public Const colorLightGray = &HD3D3D3
Public Const colorLightSlateGray = &H998877
Public Const colorLightSteelBlue = &HDEC4B0
Public Const colorRed = &HFF&
Public Const colorWhite = &HFFFFFF
Public Const colorYellow = &HFFFF&
Public Const colorSilver = &HC0C0C0

Private Const cmdArrowWidth = 285
Private Const WS_EX_RIGHT = &H1000 ' Alignment use extended sytle
Private Const GWL_EXSTYLE = (-20)
Private Const GWL_STYLE = (-16)
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long

'Aligns TextBox ComboBox Group Controls
Public Sub AlignTextBoxToComboBox(Combo1 As ComboBox, Text1 As TextBox)
    Text1.Top = Combo1.Top
    Text1.Left = Combo1.Left + cmdArrowWidth
    Text1.Width = Combo1.Width - cmdArrowWidth
    Text1.Height = Combo1.Height
End Sub

Public Function Split(ByVal sIn As String, Optional sDelim As _
      String, Optional nLimit As Long = -1, Optional bCompare As _
       VbCompareMethod = vbBinaryCompare) As Variant
    Dim sRead As String, sOut() As String, nC As Integer
    If sDelim = "" Then
        Split = sIn
    End If
    sRead = ReadUntil(sIn, sDelim, bCompare)
    Do
        ReDim Preserve sOut(nC)
        sOut(nC) = sRead
        nC = nC + 1
        If nLimit <> -1 And nC >= nLimit Then Exit Do
        sRead = ReadUntil(sIn, sDelim)
    Loop While sRead <> ""
    ReDim Preserve sOut(nC)
    sOut(nC) = sIn
    Split = sOut
End Function

Public Function ReadUntil(ByRef sIn As String, _
      sDelim As String, Optional bCompare As VbCompareMethod _
    = vbBinaryCompare) As String
    Dim nPos As String
    nPos = InStr(1, sIn, sDelim, bCompare)
    If nPos > 0 Then
        ReadUntil = Left(sIn, nPos - 1)
        sIn = Mid(sIn, nPos + Len(sDelim))
    End If
End Function


